<template>
  <div>
    <button @click="getData()">查看历史上的今天</button>
    <span v-show="loading">加载中</span>
    <p v-for="obj in dataList" :key="obj.year">{{ obj.year }} 年发生了 {{ obj.title }}</p>
  </div>
</template>

<script>
export default {
  data(){
    return{
      dataList: [],
      loading: false
    }
  },
  methods:{
    getData(){
      this.loading = true
      this.$axios({
        url: 'https://qqlykm.cn/api/free/history/get',
        method: 'get',
        params:{
          key: '9huJUUF6UmpDR1vxysbEE1yfMC'
        }
      }).then(res => {
        this.dataList = res.data.data
          this.loading = false
      })
    }
  }
}
</script>

<style>

</style>